<template>
  <div class="basic_info">
    <div class="content">
      <!-- 头部 -->
      <!-- <div class="title">账套管理</div> -->
      <div class="activeBtn">
        <button class="btn basic" :class="isActive ? 'Active' : ''" @click="handleBusiness">账套信息</button>
        <button class="btn" @click="handleBasic" :class="isActive ? '' : 'Active'">公司信息</button>
      </div>
      <AccountInfo
        v-show="isActive"
        :bookDetail="bookDetail"
        @onCancel="onCancel"
        @onAddSubmit="onAddSubmit"
      ></AccountInfo>
      <CompanyInfo
        v-show="!isActive"
        :bookDetail="bookDetail"
        @onCancel="onCancel"
        @onAddSubmit="onAddSubmit"
      ></CompanyInfo>
    </div>
  </div>
</template>

<script>
import AccountInfo from '@/views/setting/ManagementZT/info/accountInfo.vue'
import CompanyInfo from '@/views/setting/ManagementZT/info/companyInfo.vue'
import { getAction, putAction } from '../../../../api/manage'
export default {
  name: 'redactMessage',
  props: {
    accountBookId: String,
  },
  data () {
    return {
      isActive: true,
      bookDetail: {}
    }
  },
  watch: {
    accountBookId (val) {
      // this.bookDetail = {
      //   id: val
      // }
      this.getBookDetail()
    }
  },
  mounted () {
    console.log(this.accountBookId);
    // this.bookDetail = {
    //   id: this.accountBookId
    // }
    this.getBookDetail()
  },
  methods: {
    getBookDetail () {
      getAction('/accountbookinfo/xghAccountBook/queryById', { id: this.accountBookId }).then(res => {
        console.log(res);
        if (res.success) {
          this.bookDetail = res.result
        } else {
          this.$elMessage.error(res.message)
        }
      })
    },
    handleBusiness () {
      this.isActive = true
    },
    handleBasic () {
      this.isActive = false
    },
    onCancel () {
      this.$emit('onCancel')
    },
    onAddSubmit (data) {
      putAction('/accountbookinfo/xghAccountBook/edit', data).then(res => {
        if (res.success) {
          this.$elMessage.success(res.message)
          this.$emit('onAddSubmit')
        } else {
          this.$elMessage.error(res.message)
        }
      })
    }
  },
  components: {
    AccountInfo,
    CompanyInfo,
  },
}
</script>

<style lang="scss" scoped>
.content {
  padding: 0 0.5rem;
  margin-top: 0.375023rem;
  box-sizing: border-box;

  .activeBtn {
    width: 84%;
    display: flex;
    justify-content: center;
    margin-top: 0.281268rem;
  }
  .title {
    color: #1b94fb;
    box-sizing: border-box;
    font-size: 0.300019rem;
    line-height: 22px;
    font-weight: 600;
    padding-bottom: 0.375023rem;
    border-bottom: 0.018751rem solid #ddd;
    font-family: PingFang SC;
  }
  .containerContent {
    display: flex;
    margin-top: 0.468779rem;
    // justify-content: space-around;
    .one {
      width: 5.250328rem;
      &:last-child {
        margin-right: 1.406338rem;
      }
      .checkbox {
        margin-top: 0.375023rem;
        .lastCheckbox {
          padding-bottom: 0.375023rem;
          width: 100%;
          border-bottom: 1px solid #eeeeee;
        }
        .radio {
          margin-top: 0.375023rem;
        }
      }
      .infotitle {
        padding-bottom: 0.187512rem;
        font-size: 14px;
        font-family: PingFang SC;
        font-weight: 500;
        line-height: 22px;
        border-bottom: 0.018751rem solid #eee;
      }
    }
  }
}
::v-deep .el-checkbox__label {
  font-size: 0.225014rem;
}
.btn {
  background: #fff;
  border: none;
  color: #666666;
  font-size: 0.225014rem;
  border-radius: 0.093756rem;
  width: 1.500094rem;
  height: 0.562535rem;
  border: 0.018751rem solid #dddddd;
}
.basic {
  margin-right: 0.375023rem;
}
::v-deep .is-checked {
  color: #1a93fa;
}
.border-top {
  margin-top: 0.375023rem;
  border-top: 1px solid #eee;
}
.handleCancel,
.handleResult {
  width: 1.12507rem;
  height: 0.562535rem;
  font-size: 0.262516rem;
  color: #666666;
  border: 1px solid #dddddd;
  border-radius: 0.093756rem;
}
.handleResult {
  background: #1890ff;
  color: #fff;
}
.resultCancel {
  margin-top: 0.750047rem;
  text-align: center;
}
.Active {
  color: #fff;
  background-color: #1993fb;
}
</style>